﻿// Copyright (c) 2012 - 2021 Jared Zheng <jaredz at outlook dot com>
// Buddha Framework is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
//
// Create : 2012-12-01 version 0.1 Jared Zheng <jaredz at outlook dot com>
// Update : 2021-03-19 version 4.0.0 Jared Zheng <jaredz at outlook dot com>

#ifndef __MAIN_HANDLER_H__
#define __MAIN_HANDLER_H__

#pragma once

#include "CommonHandler.h"

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/// 服务加载处理
class CMainHandler : public CEventHandler
{
public:
    CMainHandler(void);
    virtual ~CMainHandler(void);

    bool    Init(void);
    void    Exit(void);

    bool    Start(void);
    void    Stop(void);
    // CEventHandler
    virtual UInt OnHandle(uintptr_t utEvent, uintptr_t utData, ULLong ullParam) OVERRIDE;
    virtual UInt OnHandle(uintptr_t utEvent, CEventBase& EventRef, ULLong ullParam) OVERRIDE;
    virtual UInt OnHandle(uintptr_t utEvent, CStream& Stream, ULLong ullParam) OVERRIDE;
    virtual UInt OnHandle(uintptr_t utEvent, UInt uCount) OVERRIDE;
private:
    bool InitHandler(void);
    void ExitHandler(void);

    bool StartHandler(void);
    void StopHandler(void);
private:
    UInt              m_uStatus;
    UInt              m_uLoad;
    CCommonHandler*   m_pHandler[COMMONR_MAX];
};

#endif // __MAIN_HANDLER_H__
